export const noSpace = {
  mounted(el) {
    const inputHandler = (event) => {
      if (event.key === ' ') {
        event.preventDefault();
      }
    };
    el.addEventListener('keydown', inputHandler);
  },
  updated(el) {
    // 移除旧的事件监听器，避免多次添加
    el.removeEventListener('keydown', (event) => {
      if (event.key === ' ') {
        event.preventDefault();
      }
    });
    const inputHandler = (event) => {
      if (event.key === ' ') {
        event.preventDefault();
      }
    };
    el.addEventListener('keydown', inputHandler);
  },
};
